<template>
  <div class="container">
    <!-- 数据大屏内容展示区域 -->
    <div class="screen" ref="screen">
      <!-- 数据大屏顶部 -->
      <div class="top">
        <Top />
      </div>
      <div class="bottom">
        <div class="left">
          <Tourist class="tourist" />
          <Sex class="sex" />
          <Age class="age" />
        </div>
        <div class="center">
          <MapView class="map" />
          <Line class="line" />
        </div>
        <div class="right">
          <Rank class="rank" />
          <Year class="year" />
          <Counter class="cunt" />
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from "vue";
// 引入顶部的子组件
import Top from "./components/top/index.vue";

// 引入左侧的子组件
import Tourist from "./components/left/tourist/index.vue";
import Sex from "./components/left/sex/index.vue";
import Age from "./components/left/age/index.vue";

// 引入中间的子组件
import MapView from "./components/centre/map/index.vue";
import Line from "./components/centre/line/index.vue";

// 引入右侧的子组件
import Rank from "./components/right/rank/index.vue";
import Year from "./components/right/year/index.vue";
import Counter from "./components/right/counter/index.vue";

// 获取数据大屏展示内容盒子的DOM元素
let screen = ref();

onMounted(() => {
  screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`;
});

// 定义大屏缩放比例
function getScale(w = 1920, h = 1080) {
  const ww = window.innerWidth / w;
  const wh = window.innerHeight / h;
  return ww < wh ? ww : wh;
}

// 监视视口变化
window.onresize = () => {
  screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`;
};
</script>

<style scoped lang="scss">
.container {
  width: 100vw;
  height: 100vh;
  background: url(./images/bg.png) no-repeat;
  background-size: cover;
  .screen {
    position: fixed;
    width: 1920px;
    height: 1080px;
    // background-color: pink;
    transform-origin: left top;
    left: 50%;
    top: 50%;
    .top {
      width: 100%;
      height: 40px;
    }
    .bottom {
      display: flex;
      .left {
        flex: 1;
        height: 1040px;
        display: flex;
        flex-direction: column;
        .tourist {
          flex: 1.2;
          // background-color: red;
        }
        .sex {
          flex: 1;
          // background-color: orange;
        }
        .age {
          flex: 1;
          // background-color: pink;
        }
      }
      .right {
        flex: 1;
        display: flex;
        flex-direction: column;
        margin-left: 40px;
        .rank {
          flex: 1.2;
        }
        .year {
          flex: 1;
        }
        .cunt {
          flex: 1;
        }
      }
      .center {
        flex: 2;
        display: flex;
        flex-direction: column;
        .map {
          flex: 4;
        }
        .line {
          flex: 1;
          // background-color: orange;
        }
      }
    }
  }
}
</style>
